#0. 导包
import unittest
import random

import json
from requests_toolbelt import MultipartEncoder
import requests
from app import BASE_URL


class TestGuest(unittest.TestCase):
    def test_add_event(self):
        url = BASE_URL + "/api/add_event/"

        data =MultipartEncoder(
            fields={"name": (None, "test002"),
               "address":(None, "孝感"),
               "limit":(None, "11"),
               "start_time":(None, "2019-12-15"),
               "status":(None, "on")})
        headers = {'Content-Type': data.content_type, "Set-Cookie": "sessionid=k6kkreo5pa4kgyjlqhxia9tl7vz1ioty"}
        response = requests.post(url, headers=headers, data=data,verify=False)

        response.encoding = "utf-8"

        code = response.status_code
        print(code)
        text = response.json()
        print(text)

if __name__ == '__main__':
    unittest.main()